package irc.view;

import javax.swing.*;
import irc.controller.MenuController;

/**
 * This class is used set up the menubar
 * @since 1.0
 * @version 1.0	
 * @author Jo				
 */

public class MenuView extends JFrame {
	private MenuController mc;
	private JMenuBar menubar;
	public DesktopView desktop;
	JMenu file, edit, help;
	JMenuItem connect =new JMenuItem("Connect to server"), 
		disConnect = new JMenuItem("Disconnect from server"), exit;
	
	
	/** 
	 * Constructor. Creates the menuBar
	 * @since 1.0
	 * @version 1.0
	 * @author Jo
	 */
	public MenuView (MenuController MC)	{
		this.mc = MC;
		menubar = new JMenuBar();
	}
	
	/** 
	 * This method initiates the Menubar
	 * <p> Returns the Menubar for use in the mainview
	 * @since 1.0
	 * @version 1.0
	 * @author Jo
	 */
	public JMenuBar menuIni ()	{
		JMenu file = new JMenu("File");
		JMenu edit = new JMenu("Edit");
		JMenu help = new JMenu("Help");
		file.setMnemonic('F');
		edit.setMnemonic('R');
		menubar.add(file);
		menubar.add(edit);
		menubar.add(help);
		JMenuItem allChannels = new JMenuItem("See all channels");
		JMenuItem joinChan = new JMenuItem ("Join channel");
		JMenuItem exit = new JMenuItem("Exit");
		JMenuItem fontSettings = new JMenuItem("Font Settings");
		JMenuItem helpMe = new JMenuItem("How does this work?");
		
		file.add(connect);
		file.add(disConnect);
		file.addSeparator();
		file.add(allChannels);
		file.add(joinChan);
		file.addSeparator();
		file.add(exit);

		hideDisConnect();
		edit.add(fontSettings);
		help.add(helpMe);
		mc.fileActionlisteners(connect, disConnect, allChannels, joinChan, exit);
		mc.editActionlisteners(fontSettings);
		mc.helpActionlisteners(helpMe);
		
		return menubar;
	} 
	
	/** 
	 * Disables connect functionality
	 * @since 1.0
	 * @version 1.0
	 * @author Solveig
	 */	
	public void hideConnect() {
		disConnect.setEnabled(true);
		connect.setEnabled(false);
	}

	/** 
	 * Disables disconnect functionality
	 * @since 1.0
	 * @version 1.0
	 * @author Solveig
	 */	
	public void hideDisConnect() {
		connect.setEnabled(true);
		disConnect.setEnabled(false);
		
	}
}
